package ru.ksu.ktk.diploma.sdi.schema.convertor.impl;

import ru.ksu.ktk.diploma.sdi.schema.convertor.OWLTransformerFactory;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamSource;
import java.io.InputStream;

/**
 * @author NZhiltsov
 *         Date: 01.02.2009
 *         Time: 13:48:18
 */
public class OWLTransformerFactoryImpl implements OWLTransformerFactory {
    /**
     * path to XSL file
     */
    private String xslFilePath;
    private Transformer transformer;

    public Transformer getTransformer() throws TransformerConfigurationException {
        if (transformer == null) {
            InputStream stream = this.getClass().getResourceAsStream(xslFilePath);
            transformer = TransformerFactory.newInstance().newTransformer(
                    new StreamSource(stream));
        }
        return transformer;
    }

    public void setXslFilePath(String xslFilePath) {
        this.xslFilePath = xslFilePath;
    }
}
